import { LayoutComponent } from '../layouts/layout.component';
import { LoginComponent } from './login/pages/login.component';
// 导入路由守卫
import { AuthGuard } from '../core/guard/auth.guard';
import { LogoutGuard } from '../core/guard/logout.guard';
import { ROLE_LIST } from '../core/auth/role';
import { AclGuard } from '../core/guard/acl.guard';

// 路由配置
export const routes = [
  // 登录路由
  {
    path: '',
    redirectTo: '/login',
    pathMatch: 'full'
  },
  {
    path: 'login',
    component: LoginComponent
  },
  {
    // 一级路由
    path: 'layout',
    component: LayoutComponent,
    canActivate: [AuthGuard],
    canDeactivate: [LogoutGuard],
    // 二级路由
    children: [
      {
        path: 'layout',
        redirectTo: '/layout/monitor',
        pathMatch: 'prefix'
      },
      { // 监控中心
        path: 'monitor',
        loadChildren: './monitor/monitor.module#MonitorModule',
        data: { roles: [...ROLE_LIST.allManage, ...ROLE_LIST.allSec], breadcrumb: '监控中心' },
        canActivate: [AclGuard]
      },
      { // 看板
        path: 'bulletin-board',
        loadChildren: './bulletin-board/bulletin-board.module#BulltinBoardModule',
        data: { roles: [...ROLE_LIST.allManage, ...ROLE_LIST.allSec]},
        canActivate: [AclGuard]
      },
      { // project 项目
        path: 'project',
        loadChildren: './project/project.module#ProjectModule',
        data: { roles: [...ROLE_LIST.allManage, ...ROLE_LIST.allSec, ...ROLE_LIST.allDev], breadcrumb: '项目' },
        canActivate: [AclGuard]
      },
      { // application 应用
        path: 'application',
        loadChildren: './application/application.module#ApplicationModule',
        data: {
          roles: [...ROLE_LIST.allManage, ...ROLE_LIST.allSec, ...ROLE_LIST.allDev],
          title: '应用',
          breadcrumb: '应用'
        },
        canActivate: [AclGuard]
      },
      { // ==== 软件资产
        path: 'assets-management',
        loadChildren: './assets-management/assets-management.module#AssetsManagementModule',
        data: { breadcrumb: '软件资产' }
      },
      { // ==== 风险管控
        path: 'threat',
        loadChildren: './threat/threat.module#ThreatModule',
        data: { roles: [...ROLE_LIST.allManage, ...ROLE_LIST.allSec], breadcrumb: '风险管控' },
        canActivate: [AclGuard]
      },
      { // 平台管理
        path: 'platform',
        loadChildren: './platform/platform.module#PlatformModule',
        data: { breadcrumb: '平台管理' }
        /* data: { roles: [...ROLE_LIST.allManage, ...ROLE_LIST.allSec] },
        canActivate: [AclGuard] */
      },
      { // 设置
        path: 'setting',
        loadChildren: './setting/setting.module#SettingModule',
      },
      { // 重置密码
        path: 'reset-password',
        loadChildren: './reset-password/reset-password.module#ResetPasswordModule'
      }
    ]
  }
];
